<template>
  <div class="elm-edit">
    <elm-page-bb>
      <el-form ref="model" :model="model" size="small" label-width="80px">
        <elm-row>
          <el-form-item label="客户" prop="kh_name" :rules="[{ required: true, message: '必须填写'}]">
            <elm-cus v-model="model.kh_name"></elm-cus>
          </el-form-item>
          <el-form-item label="联系电话" prop="kn_lxdh">
            <el-input v-model="model.kn_lxdh"></el-input>
          </el-form-item>
        </elm-row>
        <el-form-item label="客户请求" prop="shqq">
          <el-input v-model="model.shqq"></el-input>
        </el-form-item>
        <el-form-item label="问题描述" prop="wtms">
          <el-input type="textarea" :rows="2" v-model="model.wtms"></el-input>
        </el-form-item>
        <el-form-item label="解决方案" prop="jjfa">
          <el-input type="textarea" :rows="2" v-model="model.jjfa"></el-input>
        </el-form-item>
        <elm-row>
          <el-form-item label="请求时间" prop="qqsj">
            <el-date-picker v-model="model.qqsj" type="datetime"   value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="接待时间" prop="jdsj">
            <el-date-picker v-model="model.jdsj" type="datetime"   value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%">
            </el-date-picker>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="处理完成时间" prop="wcsj">
            <el-date-picker v-model="model.wcsj" type="datetime"   value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="服务人员" prop="fwr">
            <elm-ei v-model="model.fwr" disabled></elm-ei>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="服务状态" prop="zt">
            <elm-code dict_type="crm_after_sales_zt" v-model="model.zt"></elm-code>
          </el-form-item>
          <el-form-item>
          </el-form-item>
        </elm-row>
        <el-form-item label="服务结果" prop="fwjg">
          <el-input v-model="model.fwjg"></el-input>
        </el-form-item>
        <elm-row>
          <el-form-item label="满意度" prop="myd" :rules="[{trigger: 'blur' ,validator: validateNumber}]" >
            <el-input v-model="model.myd">
              <template slot="append">1-10分</template>
            </el-input>
          </el-form-item>
          <el-form-item label="服务类型" prop="fwlx">
            <elm-code dict_type="crm_after_sales_fwlx" v-model="model.fwlx"></elm-code>
          </el-form-item>
        </elm-row>
        <el-form-item label="资料">
          <elm-upload module_name="biz_crm_after_sales_file" :rel_id="model.id" :multiple="true" :limit="10"  list-type="picture" tip=" "></elm-upload>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" :rows="2" v-model="model.remark"></el-input>
        </el-form-item>
      </el-form>
      <template #bottom>
        <el-button type="success" size="small" @click="submit">立即保存</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </template>
    </elm-page-bb>
  </div>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {

      model: {id: elm.newGuid(),fwr:null,myd:null},
    }
  },
  async created() {
    this.model.fwr= await this.get_user_ei();
  },
  methods: {

    async submit() {
      await this.$refs["model"].validate();
      if(this.model.myd>10)
        this.model.myd=10;
      else if(this.model.myd<1)
        this.model.myd=1;
      var res = await elm.post('/business/my/business/UpsertAs', this.model);
      if (res == true) {
        this.v('保存成功。')
        this.close();
        this.request.callVue.tablebinding();
      }
      else {
        this.error('保存失败，请稍后尝试。');
      }
    },
    async get_user_ei(){
      var res = await elm.post('/system/login/GetUserEi');
      //console.log(res);
      if(res.length>0)
        return res[0].emp_code;
      else
        return "";
    },
  }
}
</script>